package com.hhb.juc;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class Ticket {

    Lock lock = new ReentrantLock(true);

    public int num = 30;
    public  void saleTicket(){

        lock.lock();
        Condition condition = lock.newCondition();

        try{
            if (num>0){
                System.out.println(Thread.currentThread().getName()+"县城……"+"还剩 "+ num);
                num--;
            }
        }finally {
            lock.unlock();
        }

    }
}
